

//
//  BannerCell.m
//  QuDanOEM
//
//  Created by wmz on 2021/11/4.
//

#import "BannerCell.h"
@implementation BannerCell
- (void)hd_setupViews{
    [self.contentView addSubview:self.adScrollView];
}
- (void)updateConstraints{
    [self.adScrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.model.insets.left);
        make.right.mas_equalTo(-self.model.insets.right);
        make.top.mas_equalTo(self.model.insets.top);
        make.bottom.mas_equalTo(-self.model.insets.bottom);
        make.height.mas_equalTo(self.model.itemHeight);
    }];
    [super updateConstraints];
}
- (void)setGNModel:(BaseCellModel*)data{
    self.model = data;
    data.hidden = !data.history?NO:!([data.dataSource isKindOfClass:NSArray.class] && data.dataSource.count > 0);
    data.notCacheHeight = YES;
    self.adScrollView.imageURLStringsGroup = data.dataSource;
    [self setNeedsUpdateConstraints];
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index{
    
}

- (SDCycleScrollView *)adScrollView
{
    if (!_adScrollView) {
        _adScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage imageNamed:@"material_default_bg"]];
        _adScrollView.backgroundColor = QD_RGB(38, 38, 38);
        _adScrollView.currentPageDotColor = QD_RGB(250, 204, 72);
        _adScrollView.pageDotColor = QD_RGB(208, 208, 208);
        _adScrollView.showPageControl = YES;
        _adScrollView.autoScrollTimeInterval = 3;
        _adScrollView.contentMode = UIViewContentModeScaleAspectFill;
        _adScrollView.layer.cornerRadius = 8.0f;
        _adScrollView.layer.masksToBounds = YES;
        _adScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
    }
    return _adScrollView;
}
@end
